home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / FALCON / ACC / OUTLINE.ACC / PRINTER.C < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-10  |  5.8 KB  |  271 lines

  1. /* ===================================================================
  2.  * FILE: PRINTER.C
  3.  * ===================================================================
  4.  * DATE: December 9, 1992
  5.  * 
  6.  * DESCRIPTION: Fonts ACC
  7.  *
  8.  * This file handles the printer size dialog box.
  9.  *
  10.  * COMPILER: TURBO C Version 2.0
  11.  */
  12.  
  13.  
  14. /* INCLUDE FILES
  15.  * ===================================================================
  16.  */
  17. #include <sys\gemskel.h>
  18. #include <tos.h>
  19. #include <linea.h>
  20. #include <string.h>
  21. #include <stdio.h>
  22.  
  23. #include "country.h"
  24. #include "fonthead.h"
  25. #include "fonts.h"
  26. #include "mainstuf.h"
  27. #include "text.h"
  28. #include "fsmio.h"
  29. #include "mover.h"
  30. #include "front.h"
  31.  
  32.  
  33.  
  34. /* STRUCTURES
  35.  * ===================================================================
  36.  */
  37.  
  38.  
  39. /* EXTERN
  40.  * ===================================================================
  41.  */
  42. extern int AES_Version;
  43.  
  44.  
  45.  
  46. /* PROTOTYPES
  47.  * ===================================================================
  48.  */
  49. void    DoPrinter( void );
  50. int    HandlePrinter( int button, WORD *msg );
  51. void    DoPrintOK( void );
  52.  
  53.  
  54.  
  55.  
  56. /* DEFINES
  57.  * ===================================================================
  58.  */
  59. #define PRINT_HEIGHT    9
  60. #define ACTIVE            0
  61. #define INACTIVE        1
  62.  
  63.  
  64.  
  65. /* GLOBALS
  66.  * ===================================================================
  67.  */
  68. FON_PTR print_list, print_last;
  69. int print_count;
  70. int PrintInternalFlag;
  71. int BeforeCount;
  72. int AfterCount;
  73.  
  74.  
  75. /* FUNCTIONS
  76.  * ===================================================================
  77.  */
  78.  
  79.  
  80. /* DoPrinter()
  81.  * ===================================================================
  82.  */
  83. void
  84. DoPrinter( void )
  85. {
  86.     DEV_PTR  curptr;
  87.     FON_PTR  fonptr;
  88.     int      i;
  89.  
  90.     Reset_Tree( ad_printer );
  91.  
  92.     /* Read in the UnUsed fonts, if necessary
  93.      * This way, we have a list of ALL fonts.
  94.      */
  95.     
  96.     if( !Fonts_Loaded )
  97.     {
  98.       MF_Save();
  99.       Scan_Message( ad_scan, TRUE );    
  100.  
  101.       read_fonts( TRUE, FALSE );
  102.  
  103.       Scan_Message( ad_scan, FALSE );
  104.       MF_Restore();
  105.     }  
  106.  
  107.     free_arena_links();
  108.     print_count = build_specific_list( &print_list, &print_last, BITMAP_FONT );
  109.  
  110.     /* Find the printer device */
  111.     curptr = find_device( 21 );
  112.  
  113.     /* Find and set to SELECTED, the printer fonts on the device */
  114.     if( curptr )
  115.     {
  116.       for( i = 0; i < DFCOUNT( curptr ); i++ )
  117.       {
  118.           fonptr = DFONT( curptr )[i];
  119.       if( fonptr )
  120.           AFLAG( fonptr ) = TRUE;
  121.       }
  122.     }
  123.  
  124.     mover_setup( print_list, print_count,
  125.          PRNTBASE, PRNTSLDR, PRNTUP, PRNTDOWN,
  126.          PLINE0, PLINE8, PLINE, 0, PRINT_HEIGHT );
  127.  
  128.     PrintInternalFlag = FALSE;    
  129.     Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); 
  130. }
  131.  
  132.  
  133.  
  134. /* HandlePrinter()
  135.  * ===================================================================
  136.  */
  137. int
  138. HandlePrinter( int button, WORD *msg )
  139. {
  140.    int     quit;
  141.    int     dclick;
  142.  
  143.    quit   = FALSE;
  144.    dclick = FALSE;
  145.    
  146.    /* Handle Double-clicking of the objects */   
  147.    if( ( button != -1 ) && ( button & 0x8000 ) )
  148.    {
  149.       button &= 0x7FFF;
  150.       dclick = TRUE;
  151.    }
  152.  
  153.  
  154.    switch( button )
  155.    {
  156.      case PRINTOK:  /* OK! Look through the fonts and find the active
  157.              * AFLAG ones. Then clear the device fonts and
  158.              * replace these ones instead.
  159.              */
  160.             if( PrintInternalFlag )
  161.             {
  162.                DoPrintOK();
  163.                SetChangeFlag();
  164.             }
  165.             
  166.             
  167.      case PRINTCAN: Deselect( button );
  168.             ClearFnodes( print_list );
  169.  
  170.             Reset_Tree( ad_options );     
  171.  
  172.             free_arena_links();
  173.             installed_count = build_list( &installed_list, &installed_last, ACTIVE );
  174.             available_count = build_list( &available_list, &available_last, INACTIVE );
  175.  
  176.             Objc_draw( tree, ROOT, MAX_DEPTH, NULL ); 
  177.                  break;
  178.  
  179.      case PLINE0:
  180.      case PLINE1:
  181.      case PLINE2:
  182.      case PLINE3:
  183.      case PLINE4:
  184.      case PLINE5:
  185.      case PLINE6:
  186.      case PLINE7:
  187.      case PLINE8:    BeforeCount = CountSelectedFonts( print_list, BITMAP_FONT );
  188.                     mover_button( button, dclick );
  189.                     AfterCount = CountSelectedFonts( print_list, BITMAP_FONT );
  190.                     if( BeforeCount != AfterCount )
  191.                        PrintInternalFlag = TRUE;
  192.              break;
  193.              
  194.      case PRNTUP:
  195.      case PRNTDOWN:
  196.      case PRNTBASE:
  197.      case PRNTSLDR:  mover_button( button, dclick );
  198.                   break;
  199.  
  200.  
  201.      case PRINTCLR:  if( form_alert( 1, alertp1 ) == 1 )
  202.                   {
  203.              BeforeCount = CountSelectedFonts( print_list, BITMAP_FONT );
  204.              if( BeforeCount )
  205.                   PrintInternalFlag = TRUE;
  206.                  Undo_Fnodes( print_list, ( FON_PTR )NULL );
  207.              }    
  208.              XDeselect( tree, PRINTCLR );
  209.              break;
  210.  
  211.  
  212.      default:     if( button == -1 )
  213.               {
  214.                 switch( msg[0] )
  215.                 {
  216.                   case WM_REDRAW: 
  217.                                break;
  218.                                    
  219.                   case AC_CLOSE:  quit = TRUE;
  220.                                break;
  221.                                        
  222.                   case WM_CLOSED: quit = TRUE;
  223.                                if( PrintInternalFlag )
  224.                                {
  225.                         DoPrintOK();
  226.                         SetChangeFlag();
  227.                      }   
  228.                                CloseWindow();
  229.                      break;
  230.  
  231.              case CT_KEY:
  232.                           break;
  233.                   default:
  234.                           break;
  235.                 }
  236.               }
  237.               break;
  238.    }
  239.    return( quit );
  240.  
  241.  
  242. }
  243.  
  244.  
  245.  
  246.  
  247. /* DoPrintOK()
  248.  * ===================================================================
  249.  * Clear the printer devices fonts and then add in our newly selected ones.
  250.  */
  251. void
  252. DoPrintOK( void )
  253. {
  254.     DEV_PTR  curptr;
  255.     FON_PTR  fon_ptr;
  256.  
  257.     curptr = find_device(21);
  258.     if( curptr )
  259.     {
  260.         ClearDeviceFont( curptr );
  261.  
  262.         fon_ptr = print_list;
  263.     while( fon_ptr )
  264.         {
  265.         if( AFLAG( fon_ptr ) )
  266.         add_to_device( curptr, fon_ptr );
  267.         fon_ptr = FNEXT( fon_ptr );
  268.         }
  269.     }
  270. }
  271.